﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;

/// <summary>
/// Summary description for clsRoleDAL
/// </summary>
public class clsRoleDAL
{
    InstantNaukriDataContextDataContext objInstantNaukriDataContextDataContext = new InstantNaukriDataContextDataContext();
    public clsRoleDAL()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    public List<IN_TB_ROLE> GetAllRole()
    {
        try
        {
            List<IN_TB_ROLE> objIIN_TB_ROLE = new List<IN_TB_ROLE>();
            objIIN_TB_ROLE = (from obj in objInstantNaukriDataContextDataContext.IN_TB_ROLEs
                              select obj).ToList();
            return objIIN_TB_ROLE;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public IN_TB_ROLE GetRoleById(int ID)
    {
        try
        {
            IN_TB_ROLE objIN_TB_ROLE = new IN_TB_ROLE();
            objIN_TB_ROLE = (from obj in objInstantNaukriDataContextDataContext.IN_TB_ROLEs
                             where obj.ID == ID
                             select obj).SingleOrDefault();
            return objIN_TB_ROLE;
        }
        catch (Exception)
        {

            throw;
        }
    }

    public int SaveRole(IN_TB_ROLE objIN_TB_ROLE)
    {
        try
        {
            IN_TB_ROLE objIN_TB_ROLED = new IN_TB_ROLE();
            objIN_TB_ROLED = (from obj in objInstantNaukriDataContextDataContext.IN_TB_ROLEs
                              where obj.ID == objIN_TB_ROLE.ID
                              select obj).SingleOrDefault();
            if (objIN_TB_ROLED != null)
            {
                objIN_TB_ROLED.ID = objIN_TB_ROLE.ID;
                objIN_TB_ROLED.ROLE = objIN_TB_ROLE.ROLE;
                objIN_TB_ROLED.CREATED_BY = objIN_TB_ROLE.CREATED_BY;
                objIN_TB_ROLED.CREATED_ON = objIN_TB_ROLE.CREATED_ON;
                objIN_TB_ROLED.MODIFIED_BY = objIN_TB_ROLE.MODIFIED_BY;
                objIN_TB_ROLED.MODIFIED_ON = objIN_TB_ROLE.MODIFIED_ON;
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_ROLED.ID;
            }
            else
            {
                objInstantNaukriDataContextDataContext.IN_TB_ROLEs.InsertOnSubmit(objIN_TB_ROLE);
                objInstantNaukriDataContextDataContext.SubmitChanges();
                return objIN_TB_ROLE.ID;
            }
        }
        catch (Exception)
        {

            throw;
        }
    }
}
